Harden TQQQ snapshot owner verification - #223
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c649c430f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if before.st_size > remaining_bytes: | ||
| _invalid("snapshot members exceed total size limit") | ||
| try: | ||
| raw = os.read(member_fd, before.st_size + 1) |
There was a problem hiding this comment.
Read regular files until the expected size is exhausted
When a regular-file read is interrupted after transferring some data, or a filesystem otherwise returns a legal short read, os.read() may return fewer bytes than requested even though the file is unchanged. This single read then makes the length check report snapshot member changed during read, so a valid snapshot can fail verification nondeterministically; accumulate reads until before.st_size + 1 bytes or EOF before performing the stability checks.
Useful? React with 👍 / 👎.
|
Fail-closed evidence-only closure for exact head |
Scope
Validation
PYTHONPATH=src python3 -m pytest -q tests/test_tqqq_r1_snapshot.pyPYTHONPATH=src python3 -m pytest -qpython3 -m ruff check src/us_equity_snapshot_pipelines/tqqq_r1_snapshot.py tests/test_tqqq_r1_snapshot.pyPYTHONPATH=src python3 -m compileall -q srcExact changed paths:
src/us_equity_snapshot_pipelines/tqqq_r1_snapshot.py,tests/test_tqqq_r1_snapshot.py.